#!/bin/sh
set -e

mkdir ./repository
find . -path "*build/libs/*.jar" -exec cp {} ./repository \;
find . -path "*build/outputs/aar/*.aar" -exec cp {} ./repository \;
echo -n "Packaging: "
ls -R ./repository

VERSION_TYPE='releases'

for file in ./repository/*-SNAPSHOT*; do
    VERSION_TYPE='snapshots'
done

ssh genie.keyple@projects-storage.eclipse.org rm -rf "/home/data/httpd/download.eclipse.org/keyple/${VERSION_TYPE}"
ssh genie.keyple@projects-storage.eclipse.org mkdir -p "/home/data/httpd/download.eclipse.org/keyple/${VERSION_TYPE}"
scp -r ./repository/* genie.keyple@projects-storage.eclipse.org:"/home/data/httpd/download.eclipse.org/keyple/${VERSION_TYPE}"
